<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>宿舍管理系统 - 宿舍管理</title>
    <link rel="stylesheet" href="/static/css/style.css">
</head>
<body>
    <div class="container">
        <h1>宿舍管理系统</h1>
        <div class="nav">
            <a href="/" class="nav-link">学生管理</a>
            <a href="/dormitory" class="nav-link active">宿舍管理</a>
            <a href="/repair" class="nav-link">维修申请</a>
            <button onclick="showAddForm()">添加宿舍</button>
        </div>

        <!-- 宿舍列表 -->
        <div class="content">
            <h2>宿舍列表</h2>
            <table id="dormitoryTable">
                <thead>
                    <tr>
                        <th>楼号</th>
                        <th>宿舍号</th>
                        <th>楼层</th>
                        <th>容量</th>
                        <th>已住人数</th>
                        <th>类型</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody id="dormitoryList">
                    <!-- 宿舍数据将通过JavaScript动态添加 -->
                </tbody>
            </table>
        </div>

        <!-- 添加/编辑宿舍表单 -->
        <div id="dormitoryForm" class="modal" style="display: none;">
            <div class="modal-content">
                <h2 id="formTitle">添加宿舍</h2>
                <form id="addEditForm" onsubmit="handleSubmit(event)">
                    <input type="hidden" id="dormitoryId">
                    <div class="form-group">
                        <label for="buildingNo">楼号:</label>
                        <input type="text" id="buildingNo" required>
                    </div>
                    <div class="form-group">
                        <label for="roomNo">宿舍号:</label>
                        <input type="text" id="roomNo" required>
                    </div>
                    <div class="form-group">
                        <label for="floor">楼层:</label>
                        <input type="number" id="floor" required min="1">
                    </div>
                    <div class="form-group">
                        <label for="capacity">容量:</label>
                        <input type="number" id="capacity" required min="1" max="8">
                    </div>
                    <div class="form-group">
                        <label for="type">类型:</label>
                        <select id="type" required>
                            <option value="男生宿舍">男生宿舍</option>
                            <option value="女生宿舍">女生宿舍</option>
                        </select>
                    </div>
                    <div class="form-buttons">
                        <button type="submit">保存</button>
                        <button type="button" onclick="hideForm()">取消</button>
                    </div>
                </form>
            </div>
        </div>

        <!-- 查看宿舍详情模态框 -->
        <div id="detailsModal" class="modal" style="display: none;">
            <div class="modal-content">
                <h2>宿舍详情</h2>
                <div id="dormitoryDetails">
                    <!-- 宿舍详情将通过JavaScript动态添加 -->
                </div>
                <div class="form-buttons">
                    <button type="button" onclick="hideDetails()">关闭</button>
                </div>
            </div>
        </div>
    </div>
    <script src="/static/js/dormitory.js"></script>
</body>
</html>